***********************************
*Author: Kelli Marquardt
*Purpose: Produce ADHD dx by sex figure (figure 1) 

*Inputs: 
*-	data/nhis_00008.dta	

*Outputs: 
*-	output/figures/fig_1.png

***********************************

ssc install schemepack, replace 
net install scheme-modern, from("https://raw.githubusercontent.com/mdroste/stata-scheme-modern/master/") 

***********************************
clear
use "../data/nhis_00008.dta"
keep year sampweight age sex addev
keep if addev==1 | addev==2

gen ADHDdx=(addev==2)
gen male=(sex==1)


***********************************
* keep ages 5-17
keep if age<=17 & age>=5


*****************************************
*collapse to sex-year average dx rate (weighted)
collapse (mean) ADHDdx [aw=sampweight], by(year male)

*define 3 year moving averages
xtset male year

generate moveave1 = (F1.ADHDdx + ADHDdx + L1.ADHDdx) / 3 * 100


*graph and save
set scheme modern


twoway line moveave1 year if male==1 ///
	|| line moveave1 year if male==0, ///
	ylabel(0(2)16, nogrid) ytitle("ADHD Diagnosis (%)") xtitle("Year") ///
	xlabel(2000(2)2020, angle(45) nogrid) ///
	text(13 2019.5 "Male", color(navy)) ///
	text(6 2019.5 "Female", color(maroon)) ///
	legend(off)
graph export "../output/figures/fig_1.png", replace

*END OF SCRIPT


